﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>@ViewData["Title"] - SmartCitiesClient</title>
    <link href="~/layui/css/layui.css" rel="stylesheet" />
    <script src="~/layui/layui.js"></script>
</head>
<body>
    <div class="layui-layout layui-layout-admin">
        <div class="layui-header">
            <div class="layui-row">
                <div class="layui-col-xs6">
                    <div class="layui-inline layui-font-gray" style="top:16px;left:20px;font-size:20px">
                        网格化治理平台
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <div class="grid-demo">
                        <ul class="layui-nav layui-layout-right" style="margin-right:25px">
                            <li class="layui-nav-item layui-hide layui-show-sm-inline-block">
                                <i class="layui-icon layui-icon-username" style="font-size: 20px; color: white;">
                                    admin
                                </i>
                                <dl class="layui-nav-child">
                                    <dd><a href="javascript:;">个人设置</a></dd>
                                    <dd><a href="javascript:;">安全设置</a></dd>
                                    <dd><a href="javascript:;">安全密码</a></dd>
                                    <dd><a href="/Users/Login">退出登录</a></dd>
                                </dl>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>

        <div class="layui-side layui-bg-black">
            <div class="layui-side-scroll">
                <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
                <ul class="layui-nav layui-nav-tree" lay-filter="menu" id="menu">
                    @* 动态读取菜单栏 *@
                </ul>
            </div>
        </div>
        <div class="layui-body">
            <div class="container">
                <main role="main">
                    @RenderBody()
                </main>
            </div>
        </div>

        <script>
            layui.use(['element', 'layer', 'util', 'jquery'], function () {
                var element = layui.element;
                var layer = layui.layer;
                var util = layui.util;
                var $ = layui.$;

                $.ajax({
                    url: "http://8.140.245.229:8000/AuthorizationGet/api/Menus/GetMenuShow",
                    type: 'GET',
                    data: {
                        UserId: localStorage["userId"]
                    },
                    success: function (data) {
                        $.each(data, function (index, item) {
                            var firstLevelMenu = '<li class="layui-nav-item">';
                            if (item.menuURL != null) {
                                firstLevelMenu += '<a href="' + item.Url + '">' + item.Name + '</a>';
                            }
                            else {
                                firstLevelMenu += '<a href="javascript:;">' + item.Name + '</a>';
                            }
                            // 渲染二级菜单
                            if (item.Children && item.Children.length > 0) {
                                firstLevelMenu += '<dl class="layui-nav-child">';
                                $.each(item.Children, function (idx, itm) {
                                    if (localStorage["userId"] == 1 && itm.Name == "上级网格中心工作台") {
                                        firstLevelMenu += '<dd>';
                                        firstLevelMenu += '<a href="' + itm.Url + '">' + itm.Name + '</a>';
                                        firstLevelMenu += '</dd>';
                                    } else if (localStorage["userId"] == 2 && itm.Name == "执行网格中心工作台") {
                                        firstLevelMenu += '<dd>';
                                        firstLevelMenu += '<a href="' + itm.Url + '">' + itm.Name + '</a>';
                                        firstLevelMenu += '</dd>';
                                    } else if (localStorage["userId"] == 3 && itm.Name == "网格员工作台") {
                                        firstLevelMenu += '<dd>';
                                        firstLevelMenu += '<a href="' + itm.Url + '">' + itm.Name + '</a>';
                                        firstLevelMenu += '</dd>';
                                    } else if (itm.Name != "上级网格中心工作台" && itm.Name != "执行网格中心工作台" && itm.Name != "网格员工作台") {
                                        firstLevelMenu += '<dd>';
                                        firstLevelMenu += '<a href="' + itm.Url + '">' + itm.Name + '</a>';
                                        firstLevelMenu += '</dd>';
                                    }
                                });
                                firstLevelMenu += '</dl>';
                            }
                            firstLevelMenu += '</li>';
                            $('#menu').append(firstLevelMenu);
                        });
                        // 初始化菜单
                        layui.element.init();
                    },
                });

                // 监听左侧菜单点击
                element.on('nav(test)', function (elem) {
                    var url = elem.context.getAttribute('href');
                    var title = elem.text();
                    // 添加选项卡
                    element.tabAdd('demo', {
                        title: title,
                        content: '<iframe src="' + url + '" frameborder="0" class="layui-iframe" scrolling="yes"></iframe>',
                        id: url
                    });
                    // 切换到对应选项卡
                    element.tabChange('demo', url);
                });

                //头部事件
                util.event('lay-header-event', {
                    menuRight: function () {  // 右侧菜单事件
                        layer.open({
                            type: 1,
                            title: '更多',
                            content: '<div style="padding: 15px;">处理右侧面板的操作</div>',
                            area: ['260px', '100%'],
                            offset: 'rt', // 右上角
                            anim: 'slideLeft', // 从右侧抽屉滑出
                            shadeClose: true,
                            scrollbar: false
                        });
                    }
                });
            });
        </script>


        @await RenderSectionAsync("Scripts", required: false)
</body>
</html>

